<?php

class SettingsModule {

    public function personal() {
        global $_FANWE;
        //判断第三方用户登录 无绑定用户
        if (substr($_FANWE['user']['email'], 0, 3) == 'sys') {

            $_FANWE['user']['email'] = null;
            //unset ($_FANWE['user']['email']);
            if (empty($_COOKIE['Show_Bind_Change']) && empty($_COOKIE['Is_Show_Bind_Change']))
                fSetCookie("Show_Bind_Change", 1);
        }

        $msg = $_FANWE['cookie']['save_personal'];
        fSetCookie('save_personal', '');
        include template('page/settings/settings_personal');
        display();
    }

    public function savePersonal() {
        global $_FANWE;

        $user = array(
            'gender' => intval($_FANWE['request']['gender']),
            'reside_province' => intval($_FANWE['request']['province']),
            'reside_city' => intval($_FANWE['request']['city']),
            'weibo' => htmlspecialchars(trim($_FANWE['request']['weibo'])),
            'introduce' => htmlspecialchars(trim($_FANWE['request']['introduce'])),
            'alipay' => htmlspecialchars(trim($_FANWE['request']['alipay'])),
        );

        $vservice = FS('Validate');

        $user_name = trim($_FANWE['request']['user_name']);
        $email = trim($_FANWE['request']['email']);

        /* -------------------------------第三方整合数据--------------------------------------------- */
        $user_field = $_FANWE['setting']['integrate_field_id'];
        $sql = "SELECT {$user_field} FROM " . FDB::table('user') . " WHERE uid = '{$_FANWE['uid']}'";
        $integrate_id = intval(FDB::resultFirst($sql));
        /* ----------------------------------------------------------------------------------------- */


        //修改用户名
        if ($user_name != $_FANWE['user']['user_name']) {
            $data = array(
                'user_name' => $user_name,
            );

            if ($_FANWE['user']['edit_name_count'] == 0 || 0 === strpos($_FANWE['user']['user_name'], 'tmp_')) {

                $validate = array(
                    array('user_name', 'required', lang('user', 'register_user_name_require')),
                    array('user_name', 'range_length', lang('user', 'register_user_name_len'), 2, 20),
                    array('user_name', '/^[\x{4e00}-\x{9fa5}a-zA-Z][\x{4e00}-\x{9fa5}a-zA-Z0-9_]+$/u', lang('user', 'register_user_name_error')),
                );

                if ($vservice->validation($validate, $data)) {
                    if (FS('User')->getUserNameExists($data['user_name'])) {
                        $msg = lang('user', 'register_user_name_exist');
                        if(isset($_GET['ajax'])) {
                            exit(json_encode(array(
                                'status' => 0,
                                'msg' => $msg
                            )));
                        }
                    } else {
                        //==================添加同步用户名修改 chenfq 2011-10-15================

                        if ($integrate_id > 0 && !FS("Integrate")->getCheckUserName($user_name, $integrate_id)) {
                            $msg = FS("Integrate")->getInfo();
                        } else {
                            if ($integrate_id > 0) {
                                FS("Integrate")->editUser($integrate_id, '', '', $user_name);
                            }

                            FDB::update('user', $data, 'uid = ' . $_FANWE['uid']);
                            FDB::query('UPDATE ' . FDB::table('user_match') . ' SET user_name = \'' . FS("Words")->segmentToUnicode($data['user_name']) . '\' WHERE uid = ' . $_FANWE['uid']);
                            FDB::query('UPDATE ' . FDB::table('user_status') . ' SET edit_name_count = edit_name_count + 1 WHERE uid = ' . $_FANWE['uid']);
                        }
                        //==================添加同步用户名修改 chenfq 2011-10-15================
                    }
                } else {
                    $msg = $vservice->getError();
                }
            }
        }

        //修改邮箱
        if (!empty($email) && !empty($_FANWE['user']['email']) && substr($_FANWE['user']['email'], 0, 3) == 'sys') {
            $data = array(
                'email' => $email
            );

            $validate = array(
                array('email', 'required', lang('user', 'register_email_require')),
                array('email', 'email', lang('user', 'register_email_error')),
            );

            if ($vservice->validation($validate, $data)) {
                if (FS('User')->getEmailExists($data['email'])) {
                    $msg = lang('user', 'register_email_exist');
                } else {
                    //==================添加同步用户名修改 chenfq 2011-10-15================

                    if ($integrate_id > 0 && !FS("Integrate")->getCheckEmail($data['email'], $integrate_id)) {
                        $msg = FS("Integrate")->getInfo();
                    } else {
                        if ($integrate_id > 0) {
                            FS("Integrate")->editUser($integrate_id, '', $data['email'], '');
                        }

                        FDB::update('user', $data, 'uid = ' . $_FANWE['uid']);
                    }
                    //==================添加同步用户名修改 chenfq 2011-10-15================
                }
            } else {
                $msg = $vservice->getError();
            }
        }

        $name = htmlspecialchars(trim($_FANWE['request']['name']));
        if(strlen($name) >= 3 && preg_match('/^\w+$/i', $name)) {
            $data = array(
                'name' => $name
            );
            FDB::update('user', $data, 'uid = ' . $_FANWE['uid']);
        }

        if(!empty($_FANWE['request']['mobile'])) {
            $mobile = strlen($_FANWE['request']['mobile']) == 11 && is_numeric($_FANWE['request']['mobile']) ? $_FANWE['request']['mobile'] : '';
            $data = array(
                'mobile' => $mobile
            );
            FDB::update('user', $data, 'uid = ' . $_FANWE['uid']);
        }

        if (empty($msg)) {
            FDB::update('user_profile', $user, 'uid = ' . $_FANWE['uid']);
            FS('User')->deleteUserCache($_FANWE['uid']);
            fSetCookie('save_personal', '');
        }else
            fSetCookie('save_personal', $msg);

        if(isset($_GET['ajax'])) {
            exit(json_encode(array(
                'status' => 1
            )));
        } else {
            fHeader("location: " . FU('settings/personal'));
        }
    }

    public function avatar() {
        global $_FANWE;
        include template('page/settings/settings_avatar');
        display();
    }

    public function saveAvatar() {
        global $_FANWE;
        $img = array();
        $img['type'] = 'avatar';
        $img['src'] = false;
        if (isset($_FANWE['request']['avatar_info'])) {
            $avartar_info = unserialize(authcode($_FANWE['request']['avatar_info'], 'DECODE'));
            if ($avartar_info['path']) {
                $img['src'] = $avartar_info['path'];
                $img['server_code'] = $avartar_info['server_code'];
            }
        } else {
            $avatar_url = trim($_FANWE['request']['user_avartar']);
            if (!empty($avatar_url) && file_exists(FANWE_ROOT . $avatar_url)) {
                $img['src'] = FANWE_ROOT . $avatar_url;
            }
        }

        if ($img['src'] !== false) {
            if ($_FANWE['user']['avatar'] > 0) {
                $img['id'] = $_FANWE['user']['avatar'];
                FS('Image')->updateImage($img, true);
            } else {
                $img = FS('Image')->addImage($img);
                FS('User')->updateAvatar($_FANWE['uid'], $img['id']);
            }
        }
        fHeader("location: " . FU('settings/avatar'));
    }

    public function password() {
        global $_FANWE;
        $sync_password = $_FANWE['cookie']['sync_password'];

        $keyid = FDB::resultFirst('SELECT keyid FROM ' . FDB::table('user_bind') . ' WHERE uid=' . $_FANWE['user']['uid']);

        if (!empty($sync_password)) {
            $sync_password = authcode($sync_password, 'DECODE');
            $msg = sprintf(lang('settings', 'setting_tip_1'), $_FANWE['setting']['site_name'], $sync_password);
        }
        if ($_FANWE['user']['password'] == md5('sys_' . substr(strtolower(md5($keyid)), 0, 6))) {
            include template('page/settings/settings_password_1');
        }else
            include template('page/settings/settings_password');
        display();
    }

    public function savePassword() {
        global $_FANWE;
        $_FANWE['request']['oldpassword'] = empty($_FANWE['request']['oldpassword']) ? 'xxxxxx' : $_FANWE['request']['oldpassword'];
        $data = array(
            'oldpassword' => $_FANWE['request']['oldpassword'],
            'newpassword' => $_FANWE['request']['newpassword'],
            'confirm_password' => $_FANWE['request']['newpasswordagain'],
        );

        $vservice = FS('Validate');
        $validate = array(
            array('oldpassword', 'required', '请输入现在的密码'),
            array('newpassword', 'range_length', '请输入正确的新密码', 6, 32),
            array('confirm_password', 'equal', '确认密码不一致', $data['newpassword']),
        );

        if (!$vservice->validation($validate, $data)) {
            $msg = $vservice->getError();
        } else {
            if (md5($data['oldpassword']) != $_FANWE['user']['password']) {
                $msg = '原密码不正确';
            } else {
                FDB::update('user', array('password' => md5($data['newpassword'])), 'uid = ' . $_FANWE['uid']);
                $msg = '修改成功';
                fSetCookie('sync_password', '');
                $user = array(
                    'uid' => $_FANWE['uid'],
                    'password' => md5($data['newpassword']),
                );

                FS('User')->setSession($user);

                //==================添加同步密码修改 chenfq 2011-10-15================
                $user_field = $_FANWE['setting']['integrate_field_id'];
                $sql = "SELECT {$user_field} FROM " . FDB::table('user') . " WHERE uid = '{$_FANWE['uid']}'";
                $integrate_id = intval(FDB::resultFirst($sql));
                //echo $integrate_id."<br>";
                if ($integrate_id > 0) {
                    FS("Integrate")->editUser($integrate_id, $data['newpassword'], '', '');
                    //echo  FS("Integrate")->getInfo();
                }
                //==================添加同步密码修改 chenfq 2011-10-15================
            }
        }

        if(isset($_GET['ajax'])) {
            exit(json_encode(array(
                'status' => $msg == '修改成功' ? 1 : 0,
                'msg' => $msg
            )));
        } else {
            include template('page/settings/settings_password');
            display();
        }
    }

    /**
     * 第三方登录用户修改密码
     * @global type $_FANWE
     */
    public function savePasswordBind() {
        global $_FANWE;
        $data = array(
            'newpassword' => $_FANWE['request']['newpassword'],
            'confirm_password' => $_FANWE['request']['newpasswordagain'],
        );

        $vservice = FS('Validate');
        $validate = array(
            array('newpassword', 'range_length', '请输入正确的新密码', 6, 32),
            array('confirm_password', 'equal', '确认密码不一致', $data['newpassword']),
        );

        if (!$vservice->validation($validate, $data)) {
            $msg = $vservice->getError();
        } else {

            FDB::update('user', array('password' => md5($data['newpassword'])), 'uid = ' . $_FANWE['uid']);
            $msg = '修改成功';
            fSetCookie('sync_password', '');
            $user = array(
                'uid' => $_FANWE['uid'],
                'password' => md5($data['newpassword']),
            );

            FS('User')->setSession($user);

            //==================添加同步密码修改 chenfq 2011-10-15================
            $user_field = $_FANWE['setting']['integrate_field_id'];
            $sql = "SELECT {$user_field} FROM " . FDB::table('user') . " WHERE uid = '{$_FANWE['uid']}'";
            $integrate_id = intval(FDB::resultFirst($sql));
            //echo $integrate_id."<br>";
            if ($integrate_id > 0) {
                FS("Integrate")->editUser($integrate_id, $data['newpassword'], '', '');
                //echo  FS("Integrate")->getInfo();
            }
            //==================添加同步密码修改 chenfq 2011-10-15================
        }

        include template('page/settings/settings_password');
        display();
    }

    public function bind() {
        global $_FANWE;

        $login_modules = getLoginModuleList();
        $bind_list = FS('User')->getUserBindList($_FANWE['uid']);

        $sync_bind_exists = $_FANWE['cookie']['sync_bind_exists'];
        if (!empty($sync_bind_exists)) {
            $sync_bind_exists = unserialize(authcode($sync_bind_exists, 'DECODE'));
            $bind_exists = sprintf(lang('settings', 'setting_tip_2'), $sync_bind_exists['short_name'], $_FANWE['setting']['site_name'], $sync_bind_exists['short_name'], $_FANWE['setting']['site_name']);
        }

        include template('page/settings/settings_bind');
        display();
    }

    public function setsyn() {
        global $_FANWE;
        $uid = $_FANWE['uid'];
        $data = array();
        $sync = array();
        $sync['weibo'] = (int) $_FANWE['request']['syn_weibo'];
        $sync['topic'] = (int) $_FANWE['request']['syn_topic'];
        $sync['medal'] = 1;
        $data['sync'] = serialize($sync);
        $type = $_FANWE['request']['cls'];
        FDB::update('user_bind', $data, "uid = $uid AND type = '$type'");
    }

    public function buyerVerifier() {
        global $_FANWE;
        $taobao_user = FS("User")->getUserBindByType($_FANWE['uid'], 'taobao');
        include template('page/settings/settings_buyerverifier');
        display();
    }

    public function bindBuyerVerifier() {
        global $_FANWE;
        require_once FANWE_ROOT . "sdks/taobao/taobao.func.php";

        $uid = $_FANWE['uid'];
        $data['is_buyer'] = 0;
        FDB::update('user', $data, "uid = $uid");

        FanweService::instance()->cache->loadCache('logins');
        $url = GetTaoBaoLoginUrl($_FANWE['cache']['logins']['taobao']['app_key']);
        $url = FU('tgo', array('url' => $url));

        fSetCookie('callback_type', 'buyer');
        fHeader("location:" . $url);
    }

    public function unBuyerverifier() {
        global $_FANWE;
        $uid = $_FANWE['uid'];
        $data['is_buyer'] = -1;
        FDB::update('user', $data, "uid = $uid");
        fHeader("location: " . FU('settings/buyerverifier'));
    }

    public function realname() {
        global $_FANWE;
        if(isset($_GET['savepcardimg']) || isset($_GET['savescardimg'])) {
            $uid = intval($_GET['uid']);
            $uid = $_FANWE['uid'] == 1 && $uid ? $uid : $_FANWE['uid'];

            $fkey = isset($_GET['savepcardimg']) ? 'card_img_p' : 'card_img_s';
            $whitelist = array('jpg', 'jpeg', 'png', 'gif');
            $name      = null;
            $error     = 'No file uploaded.';
            if (isset($_FILES)) {
            	if (isset($_FILES[$fkey])) {
                    $type = $_GET['type'] == 1 ? 1 : 2;
            	    $extension = pathinfo($_FILES[$fkey]['name'], PATHINFO_EXTENSION);
            		$tmp_name = $_FILES[$fkey]['tmp_name'];
            		$name     = './public/upload2/'.$fkey.'/'.$uid.'-'.$type.'.'.$extension;
            		$error    = $_FILES[$fkey]['error'];

            		if ($error === UPLOAD_ERR_OK) {
            			if (!in_array($extension, $whitelist)) {
            				$error = 'Invalid file type uploaded.';
            			} else {
            				if(move_uploaded_file($tmp_name, $name)) {
            				    if(isset($_GET['savepcardimg'])) {
                                    $sql = 'SELECT COUNT(*) AS num FROM '.FDB::table('wogu_realname_person').' WHERE uid = ' . $uid;
                                    $r = FDB::fetchFirst($sql);
                				    if($r['num'] == 0)
                				        FDB::insert('wogu_realname_person', array('uid' => $uid, 'card_img' => ltrim($name,'.')));
                				    else
                    				    FDB::update('wogu_realname_person', array('card_img' => ltrim($name,'.')), 'uid = ' . $uid);
                    			} else {
                                    $sql = 'SELECT COUNT(*) AS num FROM '.FDB::table('wogu_realname_shop').' WHERE uid = ' . $uid;
                                    $r = FDB::fetchFirst($sql);
                                    $realkey = $type != 2 ? 'card_img' : 'card_img2';
                				    if($r['num'] == 0)
                				        FDB::insert('wogu_realname_shop', array('uid' => $uid, $realkey => ltrim($name,'.')));
                				    else
                    				    FDB::update('wogu_realname_shop', array($realkey => ltrim($name,'.')), 'uid = ' . $uid);
                    			}
            				}
            			}
            		}
            	}
            }

            echo json_encode(array(
            	'name'  => $name,
            	'error' => $error
            ));
            exit;
        } elseif($_POST['op'] == 'savepersonal') {
            $uid = intval($_POST['uid']);
            $uid = $_FANWE['uid'] == 1 && $uid ? $uid : $_FANWE['uid'];
            $args = $_FANWE['uid'] == 1 && $uid ? array('uid' => $uid) : array();
            if(!is_numeric($_POST['card_num'])) {
                showError('错误信息', '证件号码填写不正确', FU('settings/realname', $args));
            }
            $card_type = intval($_POST['card_type']);
            $sql = 'SELECT * FROM '.FDB::table('wogu_realname_person').' WHERE uid = ' . $uid;
            $r = FDB::fetchFirst($sql);
            if(empty($r['card_img']))
                showError('错误信息', '请先上传证件图片', FU('settings/realname', $args));
            FDB::update('wogu_realname_person', array('card_type' => $card_type, 'card_num' => $_POST['card_num'], 'flag' => 1), 'uid = ' . $uid);
//		    if($r['num'] == 0)
//		        FDB::insert('wogu_realname_person', array('uid' => $_FANWE['uid'], 'card_type' => $card_type, 'card_num' => $_POST['card_num'], 'flag' => 1));
//		    else
//			    FDB::update('wogu_realname_person', array('card_type' => $card_type, 'card_num' => $_POST['card_num'], 'flag' => 1), 'uid = ' . $_FANWE['uid']);

            if(isset($_GET['ajax'])) {
                exit(json_encode(array(
                    'status' => 1
                )));
            } else {
                showSuccess('提示', '实名信息提交成功！', FU('settings/realname', $args));
            }
        } elseif($_POST['op'] == 'saveshop') {
            $uid = intval($_POST['uid']);
            $uid = $_FANWE['uid'] == 1 && $uid ? $uid : $_FANWE['uid'];
            $args = $_FANWE['uid'] == 1 && $uid ? array('uid' => $uid) : array();
            $shopname = htmlspecialchars(trim($_POST['shopname']));
            $tel = htmlspecialchars(trim($_POST['tel']));
            if(empty($shopname)) {
                if(isset($_GET['ajax'])) {
                    exit(json_encode(array(
                        'status' => 0,
                        'msg' => '商家名称不能为空！',
                    )));
                } else {
                    showError('错误信息', '商家名称不能为空！', FU('settings/realname', $args));
                }
            }

            if(empty($tel)) {
                if(isset($_GET['ajax'])) {
                    exit(json_encode(array(
                        'status' => 0,
                        'msg' => '联系电话不能为空！',
                    )));
                } else {
                    showError('错误信息', '联系电话不能为空！', FU('settings/realname', $args));
                }
            }
            // $sql = 'SELECT * FROM '.FDB::table('wogu_realname_person').' WHERE uid = ' . $uid;
            // $r = FDB::fetchFirst($sql);
            // if(empty($r)) {
            //     if(isset($_GET['ajax'])) {
            //         exit(json_encode(array(
            //             'status' => 0,
            //             'msg' => '请先提交身份认证信息！',
            //         )));
            //     } else {
            //         showError('错误信息', '请先提交身份认证信息！', FU('settings/realname', $args));
            //     }
            // }

            $sql = 'SELECT * FROM '.FDB::table('wogu_realname_shop').' WHERE uid = ' . $uid;
            $predata = $r = FDB::fetchFirst($sql);
            if(empty($r['card_img2'])) {
                if(isset($_GET['ajax'])) {
                    exit(json_encode(array(
                        'status' => 0,
                        'msg' => '请先上传证件图片',
                    )));
                } else {
                    showError('错误信息', '请先上传证件图片', FU('settings/realname', $args));
                }
            }

            // 店铺名称是否被注册
            $province = intval($_POST['province']);
            $city = intval($_POST['city']);
            $sql = 'SELECT * FROM '.FDB::table('wogu_user_shop').' WHERE name=\''.$shopname.'\' AND uid!='.$uid." AND province='$province' AND city='$city' AND notshow=0";
            $r = FDB::fetchFirst($sql);
            if(!empty($r) && $r['uid'] != 0) {
                if(isset($_GET['ajax'])) {
                    exit(json_encode(array(
                        'status' => 0,
                        'msg' => '已经有同名的火锅公司存在！',
                    )));
                } else {
                    showError('错误信息', '已经有同名的火锅公司存在！', FU('settings/realname', $args));
                }
            }

            $stype = intval($_POST['stype']);
            $auth_type = intval($_POST['auth_type'.$stype]);
            $realnameData = array(
                'stype' => $stype,
                'auth_type' => $auth_type,
                'shopname' => $shopname,
                'province' => $province,
                'city' => $city,
                'flag' => 1,
                'tel' => $tel,
                'lat' => $_POST['lat'],
                'lng' => $_POST['lng'],
                'unionpay_address' => htmlspecialchars($_POST['unionpay_address']),
                'unionpay_name' => htmlspecialchars($_POST['unionpay_name']),
                'unionpay_idcard' => htmlspecialchars($_POST['unionpay_idcard']),
            );
            if(empty($predata['shopname'])) {
                $v2 = intval($_POST['v2']);
                $realnameData['v2'] = $v2;
                $realnameData['bzj'] = intval($_POST['bzj']);
            }

            $unionpay_args = array('unionpay_name' => '姓名', 'unionpay_idcard' => '身份证号', 'unionpay_email' => '邮箱', 'unionpay_merchantname' => '商户营业执照名称', 'unionpay_merchantnum' => '社会信用统一代码/营业执照号', 'unionpay_banknum' => '开户行行号', 'unionpay_bankaccount' => '开户行帐号', 'unionpay_bankname' => '开户帐号名称', 'unionpay_address' => '营业地址');
            foreach ($unionpay_args as $arg => $argname) {
                $arg_val = htmlspecialchars(trim($_POST[$arg]));
                if(empty($arg)) {
                    if(isset($_GET['ajax'])) {
                        exit(json_encode(array(
                            'status' => 0,
                            'msg' => $argname.'不能为空！',
                        )));
                    } else {
                        showError('错误信息', $argname.'不能为空！', FU('settings/realname', $args));
                    }
                }

                $realnameData[$arg] = $arg_val;
            }
            FDB::update('wogu_realname_shop', $realnameData, 'uid = ' . $uid);
//		    if($r['num'] == 0)
//		        FDB::insert('wogu_realname_shop', array('uid' => $_FANWE['uid'], 'shopname' => $shopname, 'flag' => 1));
//		    else
//			    FDB::update('wogu_realname_shop', array('shopname' => $shopname, 'flag' => 1), 'uid = ' . $_FANWE['uid']);

            if(isset($_GET['ajax'])) {
                exit(json_encode(array(
                    'status' => 1
                )));
            } else {
                showSuccess('提示', '实名信息提交成功！', FU('settings/realname', $args));
            }
        }

        $uid = intval($_GET['uid']);
        $uid = $_FANWE['uid'] == 1 && $uid ? $uid : $_FANWE['uid'];
        $sql = 'SELECT * FROM '.FDB::table('wogu_realname_person').' WHERE uid = ' . $uid;
        $personal = FDB::fetchFirst($sql);
        $sql = 'SELECT * FROM '.FDB::table('wogu_realname_shop').' WHERE uid = ' . $uid;
        $shop = FDB::fetchFirst($sql);
        $msg1 = $personal['flag'] == 0 ? '请提交资料' : ($personal['flag'] == 1 ? '商家实名实地认证由和婚礼树合作的中国建设银行和中国银联进行认证。婚礼树将在3个工作日将资料提交至中国建设银行和中国银联。具体通过时间，以建行和银联审核时间为准。' : ($personal['flag'] == 2 ? '审核通过' : '审核未通过，请重新提交资料'));
        $msg2 = $shop['flag'] == 0 ? '请提交资料（V1：实名认证）' : ($shop['flag'] == 1 ? '商家实名实地认证由和婚礼树合作的中国建设银行和中国银联进行认证。婚礼树将在3个工作日将资料提交至中国建设银行和中国银联。具体通过时间，以建行和银联审核时间为准。' : ($shop['flag'] == 2 ? '审核通过' : '审核未通过，请重新提交资料'));

        if(isset($_GET['ajax'])) {
            exit(json_encode(array(
                'user' => $_FANWE['user'],
                'personal' => $personal,
                'shop' => $shop
            )));
        } else {
            include template('page/settings/settings_realname');
            display();
        }
    }

    public function realname_img() {
        file_put_contents('1.txt', var_export($_FILES, 1));
        exit(json_encode(array(
            'status' => 1
        )));
    }

    public function invite() {
        global $_FANWE;

        include template('page/settings/settings_invite');
        display();
    }

    public function preference() {
        global $_FANWE;

        if($_POST['dosave']) {
            FDB::update('user', array('afterlogin' => intval($_POST['afterlogin'])), 'uid = ' . $_FANWE['uid']);
            showSuccess('提示', '设置成功！', FU('settings/preference'));
        }

        include template('page/settings/settings_preference');
        display();
    }
}

?>